/****** impoer excel diem cap phep ******/
diemcapphep = function()
{	
	this.attrNames = [],
	this.inputFile = '#input_Map_Bandoquyhoach_Diemcapphep_ImageUpload_Action',
	this.create = function()
	{
		var optionSplit = arguments[0].split(';');
		if (optionSplit.length == 0) return;
		var i = 0;
		for (i = 0; i < optionSplit.length; i++) {
			var sAttr = optionSplit[i];
			sAttr = sAttr.split(':');
			if (sAttr.length != 2)
				continue;
			var sKey = base.trim(sAttr[0]).toLowerCase();
			var sValue = base.trim(sAttr[1]);
			this.attrNames[sKey] = sValue;
		}
		return this;
	};
	
	this.importExcelDCP = function()
	{
		if($(this.inputFile).val() == '')
		{
			alert(LANGUAGE["msg_import_excel_empty"]);
			return;
		}
		excelTool.arrayAsset = [];
		var objDiemCapPhep = $("#divPreview_Map_Bandoquyhoach_Diemcapphep_ImageUpload_Action").text();
		objDiemCapPhep = base.trim(objDiemCapPhep.replace(/(\r\n|\n|\r)/gm, ""));
		if(objDiemCapPhep == "0")
		{
			alert(LANGUAGE["msg_import_excel_empty"]);
		}
		else if(objDiemCapPhep == "1")
		{
			alert(LANGUAGE["msg_import_excel_not_avalid"]);
		}
		else
		{
			this.arrayXML = new Array();
			 FLAG_COMPLETETED = false;
			 
			 var url_excel_file = sPortletReadExcel + "coordinate.xml";
			 
			 $.get(url_excel_file, function (data) {
				    $(data).find('elements').each(function () {
				        var $alias = $(this);
				        $alias.find('element').each(function () {
				            var $fieldAlias = $(this);
				            var _sogiayphep = "";
				            if($fieldAlias.attr('node0') != null) _sogiayphep = $fieldAlias.attr('node0');
				            var _maloaigiayphep = 0;				            
				            if($fieldAlias.attr('node1') != null) _maloaigiayphep = parseInt($fieldAlias.attr('node1'));
				            var _tennguoicap = "";
				            if($fieldAlias.attr('node2') != null) _tennguoicap = $fieldAlias.attr('node2');
				            var _diachi = "";
				            if($fieldAlias.attr('node3') != null) _diachi = $fieldAlias.attr('node3');				            
				            var _solancap = 0;
				            if($fieldAlias.attr('node4') != null) _solancap = parseInt($fieldAlias.attr('node4'));
				            var _maloaicongtrinh = "";
				            if($fieldAlias.attr('node5') != null) _maloaicongtrinh = $fieldAlias.attr('node5');
				            var _diachiluuhoso = "";
				            if($fieldAlias.attr('node6') != null) _diachiluuhoso = $fieldAlias.attr('node6');
				            var _solodat = "";
				            if($fieldAlias.attr('node7') != null) _solodat = $fieldAlias.attr('node7');
				            var _lodatthua = "";
				            if($fieldAlias.attr('node8') != null) _lodatthua = $fieldAlias.attr('node8');
				            var _tothuabando = "";
				            if($fieldAlias.attr('node9') != null) _tothuabando = $fieldAlias.attr('node9');
				            var _dtlodat = 0;				            
				            if($fieldAlias.attr('node10') != null) _dtlodat = parseFloat($fieldAlias.attr('node10'));
				            var _dtxaydung = 0;
				            if($fieldAlias.attr('node11') != null) _dtxaydung = parseFloat($fieldAlias.attr('node11'));
				            var _sotang = 0;
				            if($fieldAlias.attr('node12') != null) _sotang = parseInt($fieldAlias.attr('node12'));
				            var _chieucaocongtrinh = 0;
				            if($fieldAlias.attr('node13') != null) _chieucaocongtrinh = parseFloat($fieldAlias.attr('node13'));
				            var _machigioixd = "";
				            if($fieldAlias.attr('node14') != null) _machigioixd = $fieldAlias.attr('node14');
				            var _sonha = "";
				            if($fieldAlias.attr('node15') != null) _sonha = $fieldAlias.attr('node15');
				            var _matuyendg = "";
				            if($fieldAlias.attr('node16') != null) _matuyendg = $fieldAlias.attr('node16');
				            var _maquan = "";
				            if($fieldAlias.attr('node17') != null) _maquan = parseInt($fieldAlias.attr('node17'));
				            var _maphuong = "";
				            if($fieldAlias.attr('node18') != null) _maphuong = parseInt($fieldAlias.attr('node18'));
				            var _ngaycap = "";
				            if($fieldAlias.attr('node19') != null) 
			            	{
				            	// format: dd-mm-yyyy
				            	_ngaycap = $fieldAlias.attr('node19');
				            	_ngaycap = _ngaycap.split('-');
				            	// format: yyyy-mm-dd
				            	_ngaycap = _ngaycap[2] + '-' + _ngaycap[1] + '-' + _ngaycap[0];
			            	}
				            var _ghichu = "";
				            if($fieldAlias.attr('node20') != null) _ghichu = $fieldAlias.attr('node20');				            
				            var _coorX = "";
				            if($fieldAlias.attr('node21') != null) _coorX = $fieldAlias.attr('node21');
				            var _coorY = "";
				            if($fieldAlias.attr('node22') != null) _coorY = $fieldAlias.attr('node22');	
				            var dcp = new diemcapphep();
				            dcp.create("sogiayphep:" + _sogiayphep + ";maloaigiayphep:" + _maloaigiayphep 
				            		+ ";tennguoicap:" + _tennguoicap + ";diachi:" + _diachi				            		
				            		+ ";solancap:" + _solancap + ";maloaicongtrinh:" + _maloaicongtrinh
				            		+ ";diachiluutruhoso:" + _diachiluuhoso + ";solodat:" + _solodat
				            		+ ";lodatthua:" + _lodatthua + ";tothuabando:" + _tothuabando
				            		+ ";dientichlodat:" + _dtlodat + ";dientichxaydung:" + _dtxaydung
				            		+ ";sotang:" + _sotang + ";chieucaocongtrinh:" + _chieucaocongtrinh
				            		+ ";machigioixaydung:" + _machigioixd + ";sonha:" + _sonha
				            		+ ";matuyenduong:" + _matuyendg + ";ngaycap:" + _ngaycap
				            		+ ";maquan:" + _maquan + ";maphuong:" + _maphuong
				            		+ ";ghichu:" + _ghichu + ";x:" + _coorX + ";y:" + _coorY);
				            excelTool.arrayAsset[excelTool.arrayAsset.length] = dcp; 
				        });
				        FLAG_COMPLETETED = true;
				        excelTool.import(excelTool.typeAsset.diemcapphep, LayerAssetName.diemCapphep);
				    });
				});
		}
		$("#divPreview_Map_Bandoquyhoach_Diemcapphep_ImageUpload_Action").empty();
	};

	this.updateFeature = function()
	{
		
	};
};

var diemCP = new diemcapphep();
/****************************************/